********************************************************************************
********************************************************************************
*********** Racial Resentment vs. Principled Conservatism: 2016 Data ***********
********************************************************************************
********************************************************************************

use "Clean Data, 2016"
	
********************************************************************************	
	
****
** Correlational analyses
****	

corrci ideo2 spending2
corrci ideo2 biggov2 

corrci ideo2 raceresentsum2
corrci spending2 raceresentsum2
corrci biggov2 raceresentsum2

****
** IRT-Logit DIF analyses
****

sum spending2 if conserv == 1 
gen dumspend = 0 if spending2 <= .4845711
replace dumspend = 1 if spending2 > .4845711

gen dumspend = 0 if spending2 <= .4662392
replace dumspend = 1 if spending2 > .4662392


sum biggov2 if conserv == 1
gen dumgov = 0 if spending2 <= .6755657
replace dumgov = 1 if spending2 > .6755657

gen dumgov = 0 if spending2 <= .7611001
replace dumgov = 1 if spending2 > .7611001


preserve
difdetect favors conditions deserve tryhard, ru(spend) ///
	ab(origirt) gr(dumspend)

keep caseid theta_spend
*save "theta_spend.dta", replace	
restore	
	
preserve	
difdetect favors conditions deserve tryhard, ru(conserv) ///
	ab(origirt) gr(conserv) 
keep caseid theta_conserv
*save "theta_conserv.dta", replace	
restore	
	
preserve	
difdetect favors conditions deserve tryhard, ru(gov) ///
	ab(origirt) gr(dumgov)
keep caseid theta_gov
*save "theta_gov.dta", replace	
restore	

merge 1:1 caseid using "theta_spend.dta"
drop _merge
merge 1:1 caseid using "theta_conserv.dta"
drop _merge
merge 1:1 caseid using "theta_gov.dta"

********************************************************************************

*****
** Do corrections matter?
*****

sum theta_spend, meanonly
gen theta_spend2 = (theta_spend - r(min))/(r(max) - r(min)) 

sum theta_conserv, meanonly
gen theta_conserv2 = (theta_conserv - r(min))/(r(max) - r(min)) 

sum theta_gov, meanonly
gen theta_gov2 = (theta_gov - r(min))/(r(max) - r(min)) 

corr origirt theta_conserv theta_spend theta_gov

	
* Aid to minorities	
reg selfaid2 origirt2 spending2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
reg selfaid2 theta_conserv2 spending2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
	
reg selfaid2 origirt2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
reg selfaid2 theta_spend2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	

reg selfaid2 origirt2 ideo2 spending2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

reg selfaid2 theta_gov2 ideo2 spending2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
	
* Preferential hiring for blacks	
reg prefhire2 origirt2 spending2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
reg prefhire2 theta_conserv2 spending2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
	
reg prefhire2 origirt2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
reg prefhire2 theta_spend2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
	
reg prefhire2 origirt2 ideo2 spending2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
reg prefhire2 theta_gov2 ideo2 spending2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south


* Health insurance	
reg selfinsure2 origirt2 spending2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
reg selfinsure2 theta_conserv2 spending2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
	
reg selfinsure2 origirt2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

reg selfinsure2 theta_spend2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south
	
	
reg selfinsure2 origirt2 ideo2 spending2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

reg selfinsure2 theta_gov2 ideo2 spending2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

********************************************************************************

*****
** Replicating analyses with an alternatve
** measure of spending preferences excluding
** items about welfare and the poor.
*****

corr ideo2 spending2 spendalt2 biggov2 

reg origirt2 spendalt2 biggov2 ideo2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south if white == 1, beta 
	
* DIF corrections	
sum spendalt2 if conserv == 1 
gen dumspendalt = 0 if spendalt2 <= .3799655
replace dumspendalt = 1 if spendalt2 > .3799655

preserve
difdetect favors conditions deserve tryhard, ru(spend) ///
	ab(origirt) gr(dumspend)

keep caseid theta_spend
save "theta_spendalt.dta", replace	
restore	

merge 1:1 caseid using "theta_spendalt.dta"

sum theta_spend, meanonly
gen theta_spend2 = (theta_spend - r(min))/(r(max) - r(min)) 


* Regression models
reg selfaid2 theta_spend2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

reg prefhire2 theta_spend2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

reg selfinsure2 theta_spend2 ideo2 biggov2 pid2 interest2 edu2 income2 age2 ///
	equality2 morality2 econeval2 female south

********************************************************************************
	
*****
** MIMIC approach to DIF
** detection (results appear
** in supplemental appendix)
*****

* Spending attitudes
sem (RR -> favors conditions deserve tryhard) ///
	(dumspend -> RR)
estat mindices


gsem (RR -> favors conditions deserve tryhard) ///
	(dumspend -> RR favors), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(dumspend -> RR conditions), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(dumspend -> RR deserve), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(dumspend -> RR tryhard), ologit
	
gsem (RR -> favors conditions deserve tryhard) ///
	(0: RR@a1 -> deserve) (1: RR@a2 -> deserve), ///
	ologit ginvariant(all) group(hispend)
predict rr_spending, latent	

corr raceresentsum rr_spending	


* Big government attitudes
sem (RR -> favors conditions deserve tryhard) ///
	(dumgov -> RR)
estat mindices


gsem (RR -> favors conditions deserve tryhard) ///
	(dumgov -> RR favors), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(higov -> RR conditions), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(higov -> RR deserve), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(higov -> RR tryhard), ologit
	

gsem (RR -> favors conditions deserve tryhard) ///
	(higov -> RR tryhard conditions deserve), ologit
	
gsem (RR -> favors conditions deserve tryhard) ///
	(0: RR@a1 -> tryhard) (1: RR@a2 -> tryhard), ///
	ologit ginvariant(all) group(dumgov)
predict rr_biggov, latent	

corr raceresentsum rr_biggov

	
* Self-identifications
sem (RR -> favors conditions deserve tryhard) ///
	(conserv -> RR)
estat mindices

gsem (RR -> favors conditions deserve tryhard) ///
	(conserv -> RR favors), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(conserv -> RR conditions), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(conserv -> RR deserve), ologit

gsem (RR -> favors conditions deserve tryhard) ///
	(conserv -> RR tryhard), ologit
	
gsem (RR -> favors conditions deserve tryhard) ///
	(conserv -> RR tryhard conditions favors), ologit
	
